from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)


#数据库连接通用接口：是由用户名密码配置信息组成的单行类似网址的URI形式
# 数据库驱动名：//username:password@服务器ip：端口/数据库名
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@localhost:3306/test'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

db = SQLAlchemy(app)
@app.route('/')
def hello_world():
    return 'Hello World!'
class User (db.Model):
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(80),unique=True,nullable=False)
    email = db.Column(db.String(80),unique=True,nullable=False)

    def __repr__(self):
        return '<User{}>'.format(self.username)
db.create_all()

if __name__ == '__main__':
    app.run()
